﻿@model ZhongheCms.Models.GswTblCustomer
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var panelId = "";
    var chkName = "";
    var chkFlag = "";

}

<div class="row">
    <div class="col-xs-12 col-sm-12 widget-container-col">
        @using (Html.BeginForm("Create", "Authorize", new { id = Model.Id,userid=Model.GswTblUser.Id, ViewBag.m, ViewBag.f, ViewBag.p, ViewBag.fid, ViewBag.sdate, ViewBag.edate, ViewBag.keywords }, FormMethod.Post,
            new { name = "myForm", id = "myForm", @class = "form-horizontal", role = "form" }))
        {
            <div class="widget-box">
                <div class="widget-header">
                    <h5 class="widget-title">@ViewBag.f</h5>

                    <div class="widget-toolbar">
                    </div>
                </div>

                <div class="widget-body">


                    <div class="widget-main">

                        <div class="form-group">
                            <table id="sample-table-1" class="table table-bordered table-hover">
                                <tbody>
                                    <tr>
                                        
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">客户
                                        </td>
                                        <td>

                                          @Model.CusShortName

                                        </td>

                                    </tr>
                                   
                                    <tr>

                                        <td class="align-right" style="width: 15%; background: #f6f6f6">真实姓名
                                        </td>
                                        <td >
                                            <input  id="TrueName" name="TrueName" placeholder="" type="text" class="col-xs-10 col-sm-5" value="@Model.GswTblUser.TrueName" data-val="true" data-val-required="字段不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="TrueName" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>

                                    <tr>

                                        <td class="align-right" style="width: 15%; background: #f6f6f6">用户名
                                        </td>
                                        <td >
                                            <input  id="UserName" name="UserName" placeholder="" type="text" class="col-xs-10 col-sm-5" value="@Model.GswTblUser.UserName" data-val="true" data-val-required="字段不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="UserName" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>
                                    @if (Model.GswTblUser.Id == 0)
                                    {
                                         <tr>

                                        <td class="align-right" style="width: 15%; background: #f6f6f6">密码
                                        </td>
                                        <td >
                                            <input  id="Pwd" name="Pwd" placeholder="" type="password" class="col-xs-10 col-sm-5" value="" data-val="true" data-val-required="字段不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="Pwd" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>
                                    }
                                   



                                   


                                </tbody>
                            </table>
                        </div>

                        <div id="accordion" class="accordion-style1 panel-group">
                                @foreach (var item in Model.GswTblModuleTexts)
                                {
                                    panelId = "p" + item.Id;
                                    
                                    <div class="panel panel-default">
											<div class="panel-heading">
												<h4 class="panel-title">
													<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#@panelId">
														<i class="ace-icon fa fa-angle-down bigger-110" data-icon-hide="ace-icon fa fa-angle-down" data-icon-show="ace-icon fa fa-angle-right"></i>
														&nbsp;@item.ModuleText
													</a>
												</h4>
											</div>

											<div class="panel-collapse collapse" id="@panelId">
												<div class="panel-body">
													    <table class="table table-bordered table-hover">
                                                    <thead>
                                                        <tr>
                                                            <th class="center">选择
                                                            </th>

                                                            <th>模块
                                                            </th>

                                                            <th>备注
                                                            </th>

                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        @foreach (var subitem in item.Funcions)
                                                        {
                                                            chkName = "chk" + subitem.Id;
                                                            chkFlag = "";
                                                            if (Model.UserPowers.Count > 0)
                                                            {
                                                                if (Model.UserPowers.Any(x => x.FunId == subitem.Id))
                                                                {
                                                                    chkFlag = "checked";
                                                                }


                                                            }
                                                            <tr>
                                                                <td class="center">
                                                                    <input type="checkbox" id="@chkName" name="@chkName" value="@item.Id" @chkFlag/>
                                                                </td>
                                                                <td>
                                                                    @subitem.FuncName
                                                                    @if (!string.IsNullOrEmpty(subitem.ActionParam))
                                                                    {
                                                                        <span>(@subitem.ActionParam)</span>
                                                                    }

                                                                </td>
                                                                <td>
                                                                   @subitem.Remark
                                                                </td>



                                                            </tr>
                                       
                                                        }
                                                    </tbody>
                                                </table>
												</div>
											</div>
										</div>
                                }
										

								
									</div>
                        @if (ViewBag.scode == "1")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-ok"></i>
                                    提示信息
                                </strong>

                                信息保存成功!
																
                            </div>
                        }
                        @if (ViewBag.scode == "0")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-danger">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-remove"></i>
                                    错误提示
                                </strong>

                                @Html.ValidationSummary(true)

                            </div>

                        }
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-check bigger-110"></i>
                                    保存&nbsp;&nbsp;
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="button" onclick="funBack()">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-undo bigger-110"></i>
                                    返回&nbsp;&nbsp;
                                </button>
                            </div>
                        </div>




                    </div>



                </div>

            </div>
        }

    </div>


</div>
@section js{
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.bootstrap.js"></script>
   
    <script type="text/javascript">
     
        function funBack() {
            document.location = "/Authorize/Index/0?m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&keywords=@ViewBag.keywords";
        }
    </script>
}
